<template>
    <div>
        <el-card>
            <h1>这里是子组件</h1>
            <el-alert :title="msg" />
            <el-input v-model="childMsg"></el-input>
            <hr>
            <el-button type="primary" @click="$emit('childClick',childMsg)">来自子组件的点击</el-button>
            <el-button type="primary" @click="sendMsg">发送Child子组件的消息</el-button>
            <!-- $emit('事件名称','事件的值') -->
        </el-card>
    </div>
</template>
<script>
import { ref } from "vue"
import bus from "vue3-eventbus"
export default {
    name: "Child",
    props: {
        msg: String,
    },
    setup() {
        const childMsg = ref("我是子组件的值")
        const sendMsg=function () {
            bus.emit('getMsg',childMsg.value)
            // console.log(childMsg.value);
        }
        return {
            childMsg,
            sendMsg
        }
    }
}
</script>
<style></style>